<?php /*a:1:{s:63:"I:\php\client-manage\application\admin\view\role\authority.html";i:1740620422;}*/ ?>
<!DOCTYPE html>

<html>



<head>

	<meta charset="utf-8">

	<title></title>

	<meta name="renderer" content="webkit">

	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">

	<meta name="viewport"
		content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">

	<link rel="stylesheet" href="/public/static/layuiadmin/layui/css/layui.css" media="all">

	<link rel="stylesheet" href="/public/static/layuiadmin/style/admin.css" media="all">

	<style>
		.layui-form-label {
			width: 160px !important;
		}

		.layui-input-block {
			margin-left: 190px;
		}
	</style>

</head>



<body>

	<div class="layui-fluid">

		<div class="layui-card">

			<div class="layui-card-body" style="padding: 15px;">

				<form class="layui-form" method="post" lay-filter="component-form-group">

					<input type="hidden" name="id" value="<?php echo htmlentities($id); ?>">

					<input type="hidden" name="role_id" value="<?php echo htmlentities($role_id); ?>">

					<div class="layui-form-item">

						<label class="layui-form-label">模块管理</label>

						<div class="layui-input-block">

							<div id="module_tree" class="demo-tree-more"></div>

						</div>

					</div>

					<div class="layui-form-item layui-layout-admin">

						<div class="layui-input-block">

							<div class="layui-footer" style="left: 0;">

								<button class="layui-btn" lay-submit="" lay-filter="component-form-demo1">保存</button>

							</div>

						</div>

					</div>

				</form>

			</div>

		</div>

	</div>

	<script src="/public/static/layuiadmin/layui/layui.js"></script>

	<script>

		layui.config({

			base: '/public/static/layuiadmin/' // 静态资源所在路径

		}).extend({

			index: 'lib/index', // 主入口模块

			api: 'api'

		}).use(['index', 'form', 'laydate', 'api', 'tree'], function () {

			var $ = layui.$,

				admin = layui.admin,

				element = layui.element,

				layer = layui.layer,

				laydate = layui.laydate,

				api = layui.api,

				tree = layui.tree,

				form = layui.form;



			$.ajax({

				url: '<?php echo url("getModuleList"); ?>?role_id=<?php echo htmlentities($role_id); ?>', // 请求后台地址

				type: "get", // 请求方式

				cache: false, // 控制是否缓存数据（post请求默认false，而get请求会为true,容易造成页面数据缓存问题）

				async: false, // 控制同步还是异步

				success: function (data) {

					//基本演示

					tree.render({

						elem: '#module_tree',

						data: data,

						showCheckbox: true, // 是否显示复选框

						id: 'demoId1',

						isJump: false // 是否允许点击节点时弹出新窗口跳转

					});

				}

			});



			form.render(null, 'component-form-group');



			/* 监听提交 */

			form.on('submit(component-form-demo1)', function (data) {

				var dats = data.field;

				var index = parent.layer.getFrameIndex(window.name);

				var checkedData = tree.getChecked('demoId1'); // 获取选中节点的数据

				var module_ids = [];

				checkedData.map(function (item, index, ary) {

					module_ids.push(item.id)

					if (item.children) {

						item.children.map(function (items, indexs, arys) {

							module_ids.push(items.id)

							if (items.children) {

								items.children.map(function (itemd, indexd, aryd) {

									module_ids.push(itemd.id)

								});

							}

						});

					}

				});

				if (module_ids.length <= 0) {

					layer.msg("请选择模块！");

					return false;

				}

				dats.module_id = module_ids.join(",");

				// alert(JSON.stringify(dats));return false;

				layer.msg('加载中', {

					icon: 16,

					shade: 0.01

				});

				api.ajax('<?php echo url("autyfun"); ?>', 'post', 'json', dats, function (res) {

					layer.closeAll('loading');

					layer.msg(res.msg);

					parent.layer.close(index);	// 关闭当前页

				});

				return false;

			});

		});

	</script>

</body>



</html>